<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<div class="barTitle shadow"><i class="iconfont">&#xe613;</i>地址管理</div>
	<div class="table-responsive mr30 ml30">
		<table class="table table-hover table-bordered" id="addressTable">
			<thead>
				<tr>
					<td>收货人</td>
					<td>所在地区</td>
					<td>详细地址</td>
					<td>邮编</td>
					<td>电话/手机</td>
					<td>操作</td>
					<td>默认地址</td>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="models" var="address">
					<s:set var="iphone" value="#address.phone" />
					<s:set var="idef" value="#address.def"/>
					<tr>
						<td><s:property value="#address.accepter" /></td>
						<td><s:property value="#address.subarea" /></td>
						<td><s:property value="#address.detailAddress" /></td>
						<td><s:property value="#address.postcode" /></td>
						<td><s:if test="iphone==null">
						         <s:property value="#address.telephone"/>
						     </s:if> 
						     <s:else>
                                  <s:property value="#address.phone"/>
							</s:else></td>
						<td><a href="javascript:callAjax('findAddressById','',true,4,'','infoHtml','&id=<s:property value="#address.id"/>')">修改</a>|<a href="javascript:callAjax('deleteAddressById','',true,4,'','infoHtml','&id=<s:property value="#address.id"/>')">删除</a></td>
						<td>
						<s:if test="#address.def==2">
						                      默认地址
						     </s:if>
						     <s:else>
						        <span class="idefault"><a href="javascript:callAjax('setAddressDefault','',true,4,'','infoHtml','&id=<s:property value="#address.id"/>')">设为默认</a></span>
						     </s:else>
						</td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
	</div>
<div class="barTitle shadow"><i class="iconfont">&#xe625;</i>添加新地址</div>
	    <div id="warnMessage" class="col-sm-12 text-error mb15"></div>
		<form class="form-horizontal" role="form" id="address_form">
			<div class="form-group">
				<div class="col-sm-offset-1 col-sm-10">
					<label class="control-label B2">
						新增收货地址&nbsp;&nbsp;电话,手机号选填一项，其余为必填项</label>
				</div>
			</div>
			<div class="form-group">
				<label for="subarea" class="col-sm-2 control-label"> 所在地区:*</label>
				<div class="col-sm-6">
					<input id="subarea" onclick="showSelect();" type="text" class="form-control" name="subarea" value="${model.subarea }">
					
					<div id="select-area" class="ndis">
							<select class="form-control fl no-right-radius" id="s_province" name="s_province"></select>
							<select class="form-control fl no-radius" id="s_city" name="s_city"></select>
							<select class="form-control fl no-left-radius" id="s_county" onchange="showArea()" name="s_county"></select>
							<div class="cb"></div>
					</div>
					<script class="resources library" src="js/area.js" type="text/javascript"></script>
							<script type="text/javascript">
								_init_area();
							</script>
				</div>
				<div class="col-sm-4 visible-lg-block"></div>
			</div>
			<div class="form-group">
				<label for="detailAddress" class="col-sm-2 control-label">详细地址:* </label>
				<div class="col-sm-6">
					<textarea class="form-control" rows="3" cols="20" id="input2"
						style="resize:none;width: 100%;" name="detailAddress" id="detailAddress">${model.detailAddress }</textarea>
						
				</div>
				<div class="col-sm-4 visible-lg-block"></div>
			</div>
			<div class="form-group">
				<label for="postcode" class="col-sm-2 control-label">邮政编码:*</label>
				<div class="col-sm-6">
					<input type="text" class="form-control" id="postcode" name="postcode" value="${model.postcode }"
						></input>
				</div>
				<div class="col-sm-4 visible-lg-block"></div>
			</div>
			<div class="form-group">
				<label for="accepter" class="col-sm-2 control-label">收货人姓名:*</label>
				<div class="col-sm-6">
					<input type="text" class="form-control" id="accepter" name="accepter" value="${model.accepter }"
						value=""></input>
				</div>
				<div class="col-sm-4 visible-lg-block"></div>
			</div>
			<div class="form-group">
				<label for="telephone" class="col-sm-2 control-label">手机号码</label>
				<div class="col-sm-6">
					<input type="text" class="form-control" id="telephone"
						name="telephone" value="${model.telephone }"></input>
				</div>
				<div class="col-sm-4 visible-lg-block"></div>
			</div>
			<div class="form-group">
				<label for="phone" class="col-sm-2 control-label" 
					>电话号码</label>
				<div class="col-sm-6">
					<input type="text" class="form-control" id="phone" name="phone" value="${model.phone }"></input>
				</div>
				<div class="col-sm-4 visible-lg-block"></div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<div class="checkbox">
						<label> <input type="checkbox"  name="defaultAddress" id="defaultAddress" value="${model.def }">设为默认地址
						</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="btn btn-info" id="saveBtn">保存</button>
				</div>
				<input type="hidden" name="id" value="${model.id }"/>
			</div>
		</form>

<script src="js/addressInfo.js"></script>
